<?php
class Control_ActivityConf_show {
	function show() {
		$action 	= MooForm::request('action');
		$upload 	= MooForm::request('upload');
		$nowGame 	= MooForm::request('game');
		
		$game = MooObj::get('Game')->transportGame($nowGame);
		
		$platform 	= MooForm::request('platform');
		$activityNameZh 	= MooForm::request('activity');
		if($action == 1) {
			
			// 设置platform 和 activity信息
			MooObj::get('ActivityConf')->setInfo($game);
			
			// 是否上传文件
			if($upload == 1) {
				// 上传文件 并且进行 生成xml lua配置文件
				if($_FILES['file']) {
					$rs = MooObj::get('ActivityConf')->upload($_FILES['file'], $game, $activityNameZh);
					$errcodeConf = MooConfig::get('errorcode_lang');
					$res = $rs[0];
					$errorCode = $rs[1];
					if($errcodeConf[$errorCode]) {
						$result = $errcodeConf[$errorCode];
					} else {
						if($res == true) {
							$result = "success";
						} else {
							$result = "fail";
						}
					}
					
					MooView::set('result', $result);
				}
			}
			/**
			 * 根据中文活动名称 获取配置信息
			 */
			$activityInfo = MooObj::get('ActivityConf')->getActivityInfoByZh($game, $activityNameZh);
			// 英文活动名
			$activityNameEn = $activityInfo['activityNameEn'];
			$excelList = MooObj::get('ActivityConf')->getExcelList($game, $activityNameEn);
			
			if($excelList) {
				MooView::set('rootFile', $excelList);
			}
			
			$urlHead = MooConfig::get('main.downUrlHead');
			MooView::set('urlHead', $urlHead);
			
			// 读取excel文件			
			MooView::set('display', "block"); // 显示
			MooView::set('nowGame', $nowGame); 			// 游戏
			MooView::set('nowPlatform', $platform); 	// 平台
			MooView::set('nowActivity', $activityNameZh); 		// 活动
			MooView::render('activityConf');
		} else {
			
			MooView::set('display', "none"); // 显示
			MooView::render('activityConf');
		}
	}
}